/*
 * @文件描述: 通用类型定义和结构体
 * @版本: 
 * @作者: 周晨阳
 * @Date: 2021-02-04 12:13:42
 */
#ifndef TYPEDEF_H
#define TYPEDEF_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <stddef.h>
//使用模拟器运行，只能在windows上模拟运行，暂时只能用vs运行
//如果勾选此宏，将无法在keil中编译通过，取消此宏即可在keil中编译
//#define WIN_SIM 

typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
#ifdef WIN_SIM

typedef int32_t s32;
typedef int16_t s16;
typedef int8_t s8;

#define __O volatile  /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */

/* following defines should be used for structure members */
#define __IM volatile const /*! Defines 'read only' structure member permissions */
#define __OM volatile       /*! Defines 'write only' structure member permissions */
#define __IOM volatile      /*! Defines 'read / write' structure member permissions */

typedef const int32_t sc32; /*!< Read Only */
typedef const int16_t sc16; /*!< Read Only */
typedef const int8_t sc8;   /*!< Read Only */

typedef __IO int32_t vs32;
typedef __IO int16_t vs16;
typedef __IO int8_t vs8;

#ifdef __cplusplus
#define __I volatile /*!< Defines 'read only' permissions                 */
#else
#define __I volatile const /*!< Defines 'read only' permissions                 */
#endif
#define __O volatile  /*!< Defines 'write only' permissions                */
#define __IO volatile /*!< Defines 'read / write' permissions              */

typedef __I int32_t vsc32; /*!< Read Only */
typedef __I int16_t vsc16; /*!< Read Only */
typedef __I int8_t vsc8;   /*!< Read Only */

typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;

typedef const uint32_t uc32; /*!< Read Only */
typedef const uint16_t uc16; /*!< Read Only */
typedef const uint8_t uc8;   /*!< Read Only */

typedef __IO uint32_t vu32;
typedef __IO uint16_t vu16;
typedef __IO uint8_t vu8;

typedef __I uint32_t vuc32; /*!< Read Only */
typedef __I uint16_t vuc16; /*!< Read Only */
typedef __I uint8_t vuc8;   /*!< Read Only */

typedef enum
{
    RESET = 0,
    SET = !RESET
} FlagStatus,
    ITStatus;

typedef enum
{
    DISABLE = 0,
    ENABLE = !DISABLE
} FunctionalState;
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))

typedef enum
{
    ERROR = 0,
    SUCCESS = !ERROR
} ErrorStatus;
#endif
//示波器各类测量参数结构体
typedef struct oscilloscopeInfo
{
    /* data */
    char *str; //参数名字

    unsigned char ID;             //参数ID，兼序号
    float value;                  //参数数值
    int8_t unitType;              //单位是什么类型，如是电压
    char *unit;                   //数值单位的字符串，如V
    int8_t unitCode;              //单位代码
    unsigned char isShowed;       //是否显示
    unsigned long color;          //显示时候用的颜色
    void (*processFunc)(void *p); //对应的处理函数入口
} OscillInfo;

//右侧菜单栏的数据结构
typedef struct menuInfo
{
    /* data */
    char *str;                    //菜单项的名字
    uint8_t ID;                   //菜单项的ID，兼序号
    unsigned long unClickedColor; //没按下去的颜色

} MenuInfo;

//光标结构体
typedef struct cursor
{
    /* data */
    //光标类型，可以是x或y类型,等自定义类型
    uint8_t type;
    //光标id
    uint8_t ID;
    //光标的坐标值，单位为像素，以示波器窗口左上角为原点
    float pos;
    //光标位置所测的值
    float measureValue;
    //光标位置所测的单位
    char *measureUnit;
    //是否可见
    uint8_t isVisible;
    //光标颜色
    unsigned long color;
    uint8_t isActive; //是否当前可以被控制
} Cursor;
#endif